package com.mkuspis.moviebrowser.utils;

import android.content.Context;

/**
 * Utils for converting dp to pixels and vise versa.
 */
public class DisplayMetricsUtils {

    /**
     * Converts dp values to pixels.
     *
     * @param context - app context.
     * @param dpValue - dp values.
     * @return - pixels.
     */
    public static int convertDpToPixels(final Context context,
                                        final float dpValue) {
        float density = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * density);
    }

    /**
     * Converts pixels to dp.
     *
     * @param context     - app context.
     * @param pixelsValue - pixels.
     * @return - dp.
     */
    public static int convertPixelsToDp(final Context context,
                                        final float pixelsValue) {
        float density = context.getResources().getDisplayMetrics().density;
        return (int) (pixelsValue / density);
    }
}